#include "oeutils.h"


oeUtils::oeUtils(QObject *parent)
    : QObject{parent}
{

}


osg::ref_ptr<osgEarth::SkyNode> oeUtils::createSkyNode()
{
    osgEarth::SkyOptions skyOptions;
    skyOptions.ambient() = 0.5f;

    osg::ref_ptr<osgEarth::SkyNode> skyNode = osgEarth::SkyNode::create(skyOptions);
    skyNode->setName("sky");

    time_t t = time(NULL);
    tm* localTime = localtime(&t);
    osgEarth::DateTime dateTime(*localTime);
    skyNode->setDateTime(dateTime);

    return skyNode.get();
}


void oeUtils::FlyToPosition(osg::Group* node, osgViewer::Viewer* view, const osg::Vec3 pos)
{
    osgEarth::EarthManipulator* em = dynamic_cast<osgEarth::EarthManipulator*>(view->getCameraManipulator());
    if (em)
    {
        osgEarth::Viewpoint vm = em->getViewpoint();
        em->setViewpoint(osgEarth::Viewpoint("aa", pos.y(), pos.x(), pos.z(), vm.heading().value(), vm.pitch().value(), vm.range().value()), 5);
    }
}
